#include "cpu/exec/template-start.h"

#define instr call

make_helper(concat(call_i_, SUFFIX))
{
    int len = concat(decode_i_, SUFFIX)(cpu.eip + 1);//字节数
    reg_l(R_ESP) -= DATA_BYTE;//栈
    MEM_W(reg_l(R_ESP), cpu.eip + len + 1);//下一条指令位置
    cpu.eip += (DATA_TYPE_S)op_src->val;//偏移量的值    
    print_asm("call: 0x%x", cpu.eip + 1 +len);//更新eip
    return len + 1;//eip跳到下条指令加上偏移量位置
}

make_helper(concat(call_rm_, SUFFIX))
{
    int len = concat(decode_rm_, SUFFIX)(cpu.eip + 1);
	reg_l(R_ESP) -= DATA_BYTE;
	swaddr_write(reg_l(R_ESP) , 4, cpu.eip + len + 1);
	DATA_TYPE_S imm = op_src -> val;
	print_asm("call %x",imm);
	cpu.eip = imm - len - 1;
	return len + 1;
}

#include "cpu/exec/template-end.h"
